# -*- coding: utf-8 -*-
# @Time : 2022/6/28 下午4:14
# @Author : wyf
# @FileName: main.py
# @Email: yunfei.wang@innvote.com
"""
同花顺
http://q.10jqka.com.cn/
"""
import execjs
import requests


def get_data(url):
    # 获取js生成的cookie
    cookie_v = execjs.compile(open('./cookie.js').read()).call("get_cookie")

    headers = {
        "Accept": "text/html, */*; q=0.01",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Cache-Control": "no-cache",
        "Connection": "keep-alive",
        "Cookie": f"v={cookie_v}",
        "hexin-v": f"{cookie_v}",
        "Host": "q.10jqka.com.cn",
        "Pragma": "no-cache",
        "Referer": "http://q.10jqka.com.cn/",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36",
        "X-Requested-With": "XMLHttpRequest"
    }
    req = requests.get(url, headers=headers)
    print(req, req.text)


if __name__ == '__main__':
    _url = "http://q.10jqka.com.cn/index/index/board/hs/field/zdf/order/desc/page/1/ajax/1/"
    get_data(_url)
    # "A5zucmnXEhlavebJ5mbp1xBqbLBOFUA_wrlUA3adqAdqwTZrniUQzxLJJJLF"


